// 测试API连接
import axios from 'axios';

async function testApiConnection() {
  try {
    console.log('Testing API connection to localhost:8000...');
    
    // 测试健康检查
    const healthResponse = await axios.get('http://localhost:8000/health');
    console.log('Health check:', healthResponse.data);
    
    // 测试获取示例材料
    const examplesResponse = await axios.get('http://localhost:8000/examples');
    console.log('Examples:', examplesResponse.data);
    
    // 测试获取具体材料
    const materialResponse = await axios.get('http://localhost:8000/materials/mp-149');
    console.log('Material data:', materialResponse.data);
    
  } catch (error) {
    console.error('API connection failed:', error.message);
    if (error.response) {
      console.error('Response status:', error.response.status);
      console.error('Response data:', error.response.data);
    }
  }
}

testApiConnection();
